﻿Imports System.Data.SqlClient

Public Class clsTOP_FIVE
    Private cnConn As New SqlConnection
    Private Command As SqlCommand
    Public Sub CONECTAR_BD()
        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Command = New SqlCommand("INSERT INTO TOP_FIVE VALUES(@CLAVE,@PRODUCTIVIDAD,@POSICION)", cnConn)
        Command.CommandTimeout = 0

        Command.Parameters.Add(New SqlParameter("@CLAVE", SqlDbType.VarChar, 50))
        Command.Parameters.Add(New SqlParameter("@PRODUCTIVIDAD", SqlDbType.Decimal))
        Command.Parameters.Add(New SqlParameter("@POSICION", SqlDbType.Int))

        Try
            cnConn.Open()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End Try

    End Sub
    Public Sub Insertar(ByVal CLAVE As String, ByVal PRODUCTIVIDAD As Double, ByVal POSICION As Integer)
        Command.Parameters("@CLAVE").Value = CLAVE
        Command.Parameters("@PRODUCTIVIDAD").Value = PRODUCTIVIDAD
        Command.Parameters("@POSICION").Value = POSICION

        Try
            Command.ExecuteNonQuery()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Aviso")

        End Try
    End Sub
    Public Sub Cerrar_BD()
        If cnConn.State = ConnectionState.Open Then
            cnConn.Close()
        End If
    End Sub
End Class
